package com.naiterui.ehp.bs.b2c.order.controller.inner;

import com.naiterui.ehp.bp.constants.SwaggerTag;
import com.naiterui.ehp.bp.support.exception.PublicService;
import com.naiterui.ehp.bp.support.exception.ResponseVO;
import com.naiterui.ehp.bs.b2c.order.exception.OrderExceptionCodes;
import com.naiterui.ehp.bs.b2c.order.service.IOrderJobService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@Slf4j
@Api(tags = SwaggerTag.INNER_API + SwaggerTag.ORDER)
@Validated
@RestController
@RequestMapping("b2c/inner/system/orders")
public class InnerOrderJobController {

    @Autowired
    private IOrderJobService orderJobService;

    /**
     * 系统审核订单
     */
    @ApiOperation(value = "系统审核订单")
    @PostMapping("/audit")
    public ResponseVO<Void> systemAutoAuditOrder() {
        log.info("系统自动审核订单");
        this.orderJobService.systemAutoAuditOrder();
        return PublicService.returnResponseVO(OrderExceptionCodes.SUCCESS);
    }

    /**
     * 系统自动预分配仓库
     */
    @ApiOperation(value = "系统自动预分配仓库")
    @PostMapping("/warehouse")
    public ResponseVO<Void> systemAutoWarehouse() {
        log.info("系统自动预分配仓库");
        this.orderJobService.systemAutoWillWarehouse();
        return PublicService.returnResponseVO(OrderExceptionCodes.SUCCESS);
    }

    /**
     * 系统自动分配库房
     */
    @ApiOperation(value = "系统自动分配库房")
    @PostMapping("/assigned")
    public ResponseVO<Void> systemAutoAssignedWarehouse() {
        log.info("系统自动分配库房");
        this.orderJobService.systemAutoAssignedWarehouse();
        return PublicService.returnResponseVO(OrderExceptionCodes.SUCCESS);
    }

    /**
     * 系统自动取消订单
     */
    @ApiOperation(value = "系统自动取消订单")
    @PostMapping("/cancel")
    public ResponseVO<Void> cancel() {
        log.info("系统自动取消订单");
        this.orderJobService.systemAutoCancelOrder();
        return PublicService.returnResponseVO(OrderExceptionCodes.SUCCESS);
    }

    @ApiOperation(value = "更新物流信息")
    @PostMapping("/logistice")
    public ResponseVO<Void> logistice() {
        log.info("更新物流信息");
        this.orderJobService.logistice();
        return PublicService.returnResponseVO(OrderExceptionCodes.SUCCESS);
    }

}
